<?php
/*
* Author: Nguyen Hai Nam
* Module: Product
* Desc	: Introduce pick.vn and sidle pic
* Date	: 12/12/2011
*/
class ProductModule extends Pick_Core_Module{
	function ProductModule(){
		parent::Pick_Core_Module();
		# Languages
		$languages = new Pick_Core_Languages();
		$objectLanguages = "";
		$objectLanguages = $languages->getObjects(1, 'status = 1', array('position'=>'ASC'), '');
		if($objectLanguages){
			$objectLanguages = $objectLanguages['data'];	
		}#endif
		$this->template->assign("objectLanguages", $objectLanguages);
	}
	public function getContent(){

		$productcategory = new Pick_Dao_ProductCategory();
		$product = new Pick_Dao_Product();
		$id = $this->request->get('id');
		// If ID empty, it's will get default...
		if(empty($id)){
			$objproductcategorydefault = $productcategory->getObjects(1, "status=1 AND cid = 0", array('position'=>"ASC"), 1);
			if(isset($objproductcategorydefault['data'][0]) && is_object($objproductcategorydefault['data'][0])){
				$id = $objproductcategorydefault['data'][0]->getField('id');
			}	
		}
		
		// Get array subcategory
		$objCat = $productcategory->getObject($id);
        $backgroundimage = $objCat->getFullUrlBackGround();
        $this->template->assign('backgroundimage', $backgroundimage);
		$arrSubCategory = $productcategory->getSubCategory($id);
		$this->template->assign("arrSubCategory", $arrSubCategory);
		$this->template->assign("objCat", $objCat);
		unset($productcategory);
		unset($product);
		unset($objCat);
		unset($arrSubCategory);
	}
}